package com.iwjw.ibatis.plugins.dynamic.spring.aop;

import com.iwjw.ibatis.plugins.dynamic.spring.DynamicDataSourceGlobal;

/**
 * @author: huangweiwei
 * @email: ihuangweiwei@163.com
 * @created:2016/10/28
 */
public class MasterSynchronizationManager {

    private static final ThreadLocal<String> synchronizations =
            new ThreadLocal<String>() {
            };


    public static boolean isMasterActive() {
        return (synchronizations.get() != null);
    }

    public static void registerMaster() {
        synchronizations.set(DynamicDataSourceGlobal.WRITE.name());
    }

    public static void clear() {
        synchronizations.remove();
    }

}
